﻿using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using SmlEngine.Sprites;

namespace SmlEngine.Sprites.Base
{
    public class Tile : StaticSprite
    {
        public override Vector2 Position
        {
            get { return new Vector2(Bounds.X, Bounds.Y); }
            set { Collision.Origin += value - Collision.Origin; }
        }
        public override Point Size
        {
            get { return new Point((int)Collision.Width, (int)Collision.Height); }
            set { Collision = new RightTriangle(Collision.X, Collision.Y, value.X, value.Y); }
        }

        public override BoundingRectangle Bounds { get { return Collision.Bounds; } }
        public RightTriangle Collision;

        public Collision Bottom { get; set; }
        public Collision Left { get; set; }
        public Collision Right { get; set; }
        public Collision Top { get; set; }
        public Collision Slope { get; set; }

        public NpcCollideEvenHandler Collided { get; set; }

        /// <summary>
        /// Has yet to be implemented.
        /// </summary>
        public bool IsSizable { get; set; }

        public Tile()
        {
        }

        public void SetGraphics(Texture2D value)
        {
            Graphics = value;
        }

        public Tile Clone()
        {
            Tile result = new Tile();
            result.IsSizable = IsSizable;
            result.Size = Size;
            result.Position = Position;
            result.Graphics = Graphics;
            //result.Collision = Collision;

            result.Slope = Slope;
            result.Top = Top;
            result.Left = Left;
            result.Right = Right;
            result.Bottom = Bottom;
            return result;
        }
    }
}
